Component({
  properties:{
    isInFloat:Boolean,
    isShowTitle:Boolean,
    isShowMonth:{
      type:Boolean,
      value:true
    },
    montha:{
      type:Number,
      value:1
    },
    monthb:{
      type:Number,
      value:12
    },
    gjj:{
      type:String,
      value:null
    },
    gjjbase:{
      type:String,
      value:null
    },
    sb:{
      type:String,
      value:null
    },
    sbbase:{
      type:String,
      value:null
    },
    isDisabled:{
      type:Boolean,
      value:false
    },
    dqsr:{
      type:String,
      value:null
    }
  },
  data:{
    five:getApp().data.five,
    shebao:getApp().data.shebao,
    showFive:false,
    showShebao:false,
    wxyj:[],
    sqsy:[],
    monthA:12,
    monthB:1
  },
  methods:{
    pushData(){
      this.tapContinue();
      var temp = {};
      temp.wxyj = this.data.wxyj;
      temp.sqsy = this.data.sqsy;
      return temp;
    },
    checkData:function(e){
      // if(!(/^[0-9]+.?[0-9]*$/.test(e.detail.value))){
      //   wx.showToast({
      //     title: '请输入正实数哦',
      //     icon:'none',
      //     duration: 2000
      //   });
      var t = e.detail.value;
      for(var g = 0;g<t.length;g++){
        if((t[g]>'9'||t[g]<'0')&&t[g]!='.'){
          wx.showToast({
                title: '请输入正实数哦',
                icon:'none',
                duration: 1000
              });
        }
    }
    },
    //把输入的五险一金存到数组里面
    tapContinue:function(){
      //因为在result页面判断是否为空的时候行不通，所以这里就设置了一个保护范围，在这个范围之内的数据不会被变为零
      // var monthA,montha,monthB,monthb;
      // monthA = parseFloat()
      if(this.properties.montha<this.data.monthA){
        this.setData({
          monthA:this.properties.montha
        })
      }
      if(this.properties.monthb>this.data.monthB){
        this.setData({
          monthB:this.properties.monthb
        })
      }
      var event={};
      event.gjj = this.properties.gjj;
      event.gjjbase = this.properties.gjjbase;
      event.sbbase = this.properties.sbbase;
      event.sb = this.properties.sb;
      event.montha = this.properties.montha;
      event.monthb = this.properties.monthb;
      event.dqsr = this.properties.dqsr
      console.log(event);
      this.triggerEvent('addInsurance',event);
      for(var k = 0;k<12;k++){
        var gjj = "wxyj["+k+"].gjj",gjjbase = "wxyj["+k+"].gjjbase",sbbase = "wxyj["+k+"].sbbase",sb = "wxyj["+k+"].sb",dqsr = "sqsy["+k+"]";
        if(k>=(this.data.monthA-1)&&k<this.data.monthB){//先检查大范围
          if(k>=(this.properties.montha-1)&&k<this.properties.monthb){//如果再montha----monthb之间的月份，正常赋值
            this.setData({
              [gjj]:parseFloat(this.properties.gjj),
              [gjjbase]:parseFloat(this.properties.gjjbase),
              [sbbase]:parseFloat(this.properties.sbbase),
              [sb]:parseFloat(this.properties.sb),
              [dqsr]:parseFloat(this.properties.dqsr)
            });
        }}else{//不在的话就变为0
          this.setData({
            [gjj]:0,
            [gjjbase]:0,
            [sbbase]:0,
            [sb]:0
          });
        }
      }
      // console.log(this.data.wxyj)
    },
    tapDialog:function(e){
      this.setData({
        showFive:false,
        showShebao:false
      });
    },
    tapFive:function(){
      this.setData({
        showFive:true,
        showShebao:false
      });
    },
    tapShebao:function(){
      this.setData({
        showFive:false,
        showShebao:true
      })
    }
  }
})